package work.database.example.connector;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class CloserUtil {
	public static void close(Connection conn) {
		try {
			conn.close();
		} catch (SQLException e) {
			e.printStackTrace();
		} finally {
			conn = null;
		}
	}

	public static void close(PreparedStatement pstmt) {
		try {
			pstmt.close();
		} catch (SQLException e) {
			e.printStackTrace();
		} finally {
			pstmt = null;
		}
	}

	public static void close(ResultSet rs) {
		try {
			rs.close();
		} catch (SQLException e) {
			e.printStackTrace();
		} finally {
			rs = null;
		}
	}

	public static void close(PreparedStatement pstmt, Connection conn) {
		close(pstmt);
		close(conn);
	}

	public static void close(ResultSet rs, PreparedStatement pstmt,
			Connection conn) {
		close(rs);
		close(pstmt, conn);
	}
}
